from sklearn.linear_model import LinearRegression
from sklearn.datasets import load_diabetes
from sklearn.model_selection import train_test_split
ds = load_diabetes()
x,y = ds.data,ds.target
x_train,x_test,y_train,y_test = train_test_split(x,y,random_state=8)
model=linearRegression()
model.fit(x_train,y_train)
print("w=",model.coef_,"b=",model.intercept_)
r21=model.score(x_train,y_train)
r22=model.score(x_test,y_test)
print("模型在训练集上的预测准确率；",r21)
print("模型在测试集上的预测准确率；",r22)